#include <stdio.h>
#include <signal.h>

void handler(int sig);
void raise_sig(void);

int main(){
  void (*orig_handler)(int);

  printf("Installing handler for signal %d\n", SIGINT);
  orig_handler = signal(SIGINT, handler);
  raise_sig();

  printf("Changing handler to SIG_IGN\n");
  signal(SIGILL, SIG_IGN);
  raise_sig();

  printf("Restoring original handler\n");
  signal(SIGINT, orig_handler);
  raise_sig();

  printf("program terninates normally.\n");
  return 0;
}

void handler(int sig){
  printf("handler called for signal %d\n", sig);
}

void raise_sig(void){
  raise(SIGINT);
} 